package com.sg.service;

import com.sg.entity.IntegralFlow;
import com.sg.vo.FlowVO;
import com.sg.vo.UserVO;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.mapper.UserInfoMapper;
import com.sg.entity.UserInfo;

import javax.annotation.Resource;

@Service
public class UserInfoService extends ServiceImpl<UserInfoMapper, UserInfo> {

    @Resource
    private IntegralFlowService integralFlowService;

    @Resource
    private UserInfoMapper userInfoMapper;

    public List<UserVO> getInfo(Integer id) {
        return userInfoMapper.getInfo(id);
    }

    public Integer getCurrent(Integer id) {
        return userInfoMapper.getCurrent(id);
    }

    public Integer getTimes(Integer id) {
        return userInfoMapper.getTimes(id);
    }

    public List<FlowVO> flow(Integer id) {
        return userInfoMapper.flow(id);
    }

    public void hx(Integer id, Integer sl) {
        IntegralFlow integralFlow = new IntegralFlow();
        integralFlow.setUserId(id);
        integralFlow.setChangReason("积分兑换");
        integralFlow.setChangTime(new Date());
        integralFlow.setChangUnm(sl);
        integralFlowService.save(integralFlow);
    }
}
